package com.tronsis.distribution.activity.me.complaints;

import android.os.Bundle;
import android.view.View;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.tronsis.distribution.R;
import com.tronsis.distribution.bean.ReportBean;
import com.tronsis.library.activity.ToolBarBaseActivity;
import com.tronsis.library.util.DateUtil;

import java.util.List;

import butterknife.BindView;
import butterknife.ButterKnife;

public class ComplaintsDetailActivity extends ToolBarBaseActivity {

    @BindView(R.id.tv_reason)
    TextView mTvReason;
    @BindView(R.id.tv_description)
    TextView mTvDescription;
    @BindView(R.id.tv_create_time)
    TextView mTvCreateTime;
    @BindView(R.id.tv_replay)
    TextView mTvReplay;
    @BindView(R.id.tv_replay_time)
    TextView mTvReplayTime;
    @BindView(R.id.ll_replay)
    LinearLayout mLlReplay;
    @BindView(R.id.tv_no_reply)
    TextView mTvNoReply;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_complaints_detail);
        ButterKnife.bind(this);
        setTitle(true, getString(R.string.complaints_detail));

        ReportBean reportBean = (ReportBean) getIntent().getSerializableExtra("ReportBean");
        setView(reportBean);
    }

    private void setView(ReportBean reportBean) {
        if (reportBean == null) {
            return;
        }
        mTvReason.setText(getString(R.string.format_report_reason, reportBean.getReason()));
        mTvDescription.setText(getString(R.string.format_report_description, reportBean.getDetail()));
        mTvCreateTime.setText(DateUtil.getDateTimeString(reportBean.getCreatedOn()));
        List<ReportBean.RepliesBean> replies = reportBean.getReplies();
        // TODO: 2019/4/16 改成列表
        if (replies != null && !replies.isEmpty()) {
            mLlReplay.setVisibility(View.VISIBLE);
            mTvNoReply.setVisibility(View.GONE);
            ReportBean.RepliesBean repliesBean = replies.get(0);
            mTvReplay.setText(repliesBean.getContent());
            mTvReplayTime.setText(DateUtil.getDateTimeString(repliesBean.getReplyOn()));
        } else {
            mLlReplay.setVisibility(View.GONE);
            mTvNoReply.setVisibility(View.VISIBLE);
        }
    }
}
